package com.e3.basdoc.employee.client;

import java.util.List;

import com.e3.basdoc.dept.client.DeptTreePanel;
import com.e3.basdoc.dept.model.DeptModel;
import com.e3.basdoc.employee.model.EmployeeModel;
import com.e3.basdoc.employee.model.EmployeeQC;
import com.e3.template.tgf.MyTGFExUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFFormPanel;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFPagingGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class EmployeeUI extends MyTGFExUI<EmployeeModel,DeptModel> {
	
	private EmployeeRPCServiceAsync service = EmployeeRPCService.Util.getInstance();

	@Override
	protected TGFFormPanel<EmployeeModel> createFormPanel() {
		return new EmployeeFormPanel();
	}

	@Override
	protected TGFGridPanel<EmployeeModel> createGridPanel() {
		return new EmployeeGridPanel();
	}

	@Override
	protected TGFQueryDialog<EmployeeModel> createQueryDialog() {
		return new EmployeeQueryDialog();
	}

	@Override
	protected TGFEditorDialog<EmployeeModel> createEditorDialog() {
		return new EmployeeEditorDialog();
	}

	@Override
	protected void executeDeleteService(final List<EmployeeModel> models,AsyncCallback<Void> callback) {
		service.deleteEmployees(models,callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return EmployeeMessages.INSTANCE.local_name();
	}

	@Override
	protected EmployeeModel createModelInstance() {
		return EmployeeHelper.INSTANCE.createModelInstance();
	}

	@Override
	protected TGFTreePanelAsync<DeptModel> createTreePanel() {
		return new DeptTreePanel();
	}

	@Override
	protected void executeQueryService(DeptModel model,	AsyncCallback<List<EmployeeModel>> callback) {
		TGFPagingGridPanel<EmployeeModel> gridPanel = (TGFPagingGridPanel<EmployeeModel>)getGridPanel();
		EmployeeQC qc = new EmployeeQC();
		qc.setDeptId(model.getId());
		gridPanel.refreshPaging(qc);
	}

}
